<template>
  <div class="app-container">
    <table class="table table-striped table-bordered table-hover">
      <tbody><tr>
        <td style="width:60px;text-align: right;padding-top: 13px;">广告屏开启时间:</td>
        <td style="width:10px;">
          <select style="width: 50px" v-model="temp.screenOpen">
            <option v-for="(item, index) in 24" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 50px; text-align: left;padding-top: 13px;">时</td>
        <td style="width: 10px">
          <select style="vertical-align:top; width: 50px;" v-model="temp.screenOpen1">
            <option v-for="(item, index) in 60" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">分</td>
        <td style="width:60px;text-align: right;padding-top: 13px;">广告屏关闭时间:</td>
        <td style="width:10px;">
          <select style="width: 50px" v-model="temp.screenShut">
            <option v-for="(item, index) in 24" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">时</td>
        <td style="width: 10px">
          <select style="vertical-align:top; width: 50px;" v-model="temp.screenShut1">
            <option v-for="(item, index) in 60" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 5px; text-align: left;padding-top: 13px;">分</td>
      </tr>
      <tr>
        <td style="width:10px;text-align: right;padding-top: 13px;">广告灯开启时间:</td>
        <td style="width:10px;">
          <select style="width: 50px" v-model="temp.lampOpen">
            <option v-for="(item, index) in 24" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">时</td>
        <td style="width: 10px">
          <select style="vertical-align:top; width: 50px;" v-model="temp.lampOpen1">
            <option v-for="(item, index) in 60" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">分</td>
        <td style="width:10px;text-align: right;padding-top: 13px;">广告灯关闭时间:</td>
        <td style="width:10px;">
          <select style="width: 50px" v-model="temp.lampShut">
            <option v-for="(item, index) in 24" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">时</td>
        <td style="width: 10px">
          <select style="vertical-align:top; width: 50px;" v-model="temp.lampShut1">
            <option v-for="(item, index) in 60" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 5px; text-align: left;padding-top: 13px;">分</td>
      </tr>

      <tr>
        <td style="width:10px;text-align: right;padding-top: 13px;">二维码照明打开:</td>
        <td style="width:10px;">
          <select style="width: 50px" v-model="temp.lightingOpen">
            <option v-for="(item, index) in 24" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">时</td>
        <td style="width: 10px">
          <select style="vertical-align:top; width: 50px;" v-model="temp.lightingOpen1">
            <option v-for="(item, index) in 60" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">分</td>
        <td style="width:10px;text-align: right;padding-top: 13px;">二维码照明关闭:</td>
        <td style="width:10px;">
          <select style="width: 50px" v-model="temp.lightingShut">
            <option v-for="(item, index) in 24" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">时</td>
        <td style="width: 10px" v-model="temp.lightingShut1">
          <select style="vertical-align:top; width: 50px;">
            <option v-for="(item, index) in 60" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 5px; text-align: left;padding-top: 13px;">分</td>
      </tr>
      <tr>
        <td style="width:10px;text-align: right;padding-top: 13px;">提示音打开:</td>
        <td style="width:10px;">
          <select style="width: 50px" v-model="temp.promptOpen">
            <option v-for="(item, index) in 24" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">时</td>
        <td style="width: 10px">
          <select style="vertical-align:top; width: 50px;" v-model="temp.promptOpen1">
            <option v-for="(item, index) in 60" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">分</td>
        <td style="width:10px;text-align: right;padding-top: 13px;">提示音关闭:</td>
        <td style="width:10px;">
          <select style="width: 50px" v-model="temp.promptShut">
            <option v-for="(item, index) in 24" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">时</td>
        <td style="width: 10px">
          <select style="vertical-align:top; width: 50px;" v-model="temp.promptShut1">
            <option v-for="(item, index) in 60" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 5px; text-align: left;padding-top: 13px;">分</td>
      </tr>
      <tr>
        <td style="width:10px;text-align: right;padding-top: 13px;">WIFI热点开启:</td>
        <td style="width:10px;">
          <select style="width: 50px" v-model="temp.hotOpen">
            <option v-for="(item, index) in 24" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">时</td>
        <td style="width: 10px">
          <select style="vertical-align:top; width: 50px;" v-model="temp.hotOpen1">
            <option v-for="(item, index) in 60" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">分</td>
        <td style="width:10px;text-align: right;padding-top: 13px;">WIFI热点关闭:</td>
        <td style="width:10px;">
          <select style="width: 50px" v-model="temp.hotShut">
            <option v-for="(item, index) in 24" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">时</td>
        <td style="width: 10px">
          <select style="vertical-align:top; width: 50px;" v-model="temp.hotShut1">
            <option v-for="(item, index) in 60" :key="index" :value="index" :label="index"></option>
          </select>
        </td>
        <td style="width: 5px; text-align: left;padding-top: 13px;">分</td>
      </tr>
      <tr>
        <td style="width:10px;text-align: right;padding-top: 13px;">消毒周期:</td>
        <td style="width:10px;">
          <input style="width:50px;" type="text" v-model="temp.sterilizationCycle">
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">分钟</td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">消毒时长:</td>
        <td style="width: 10px">
          <input style="width:50px;" type="text" v-model="temp.disinfectionTime">
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">分钟</td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">握手周期:</td>
        <td style="width:10px;">
          <input style="width:50px;" type="text" v-model="temp.handshakeCycle">
        </td>
        <td style="width: 10px; text-align: left;padding-top: 13px;">分钟</td>
        <td style="width: 10px; text-align: left;padding-top: 13px;"></td>
      </tr>
      <tr>
        <td class="center" colspan="10">
          <el-button type="primary" size="mini" @click="save">保存</el-button>
        </td>
      </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
  import { getList, sureEdit } from '@/api/device/parameter'

  export default {
    data() {
      return {
        list: {
          screenOpen: '',
          screenShut: '',
          lampOpen: '',
          lampShut: '',
          lightingOpen: '',
          lightingShut: '',
          promptOpen: '',
          promptShut: '',
          hotOpen: '',
          hotShut: '',
          sterilizationCycle: '',
          disinfectionTime: '',
          handshakeCycle: ''
        },
        listLoading: true,
        temp: {
          screenOpen: '7',
          screenOpen1: '0',
          screenShut: '22',
          screenShut1: '0',
          lampOpen: '18',
          lampOpen1: '0',
          lampShut: '6',
          lampShut1: '0',
          lightingOpen: '18',
          lightingOpen1: '0',
          lightingShut: '6',
          lightingShut1: '0',
          promptOpen: '7',
          promptOpen1: '0',
          promptShut: '9',
          promptShut1: '0',
          hotOpen: '7',
          hotOpen1: '0',
          hotShut: '9',
          hotShut1: '0',
          sterilizationCycle: '10',
          disinfectionTime: '0',
          handshakeCycle: '10'
        },
        formsrules: {
          name: [{ required: true, message: '请输入', trigger: 'blur' }]
        }
      }
    },
    created() {
      this.fetchData()
    },
    methods: {
      fetchData() {
        this.listLoading = true
        getList(this.listQuery).then(response => {
          var resdata = response.data
          this.temp = resdata
          const a1 = resdata.screenOpen.split(',')
          this.temp.screenOpen = a1[0]
          this.temp.screenOpen1 = a1[1]
          const a2 = resdata.screenShut.split(',')
          this.temp.screenShut = a2[0]
          this.temp.screenShut1 = a2[1]
          const a3 = resdata.lampOpen.split(',')
          this.temp.lampOpen = a3[0]
          this.temp.lampOpen1 = a3[1]
          const a4 = resdata.lampShut.split(',')
          this.temp.lampShut = a4[0]
          this.temp.lampShut1 = a4[1]
          const a5 = resdata.lightingOpen.split(',')
          this.temp.lightingOpen = a5[0]
          this.temp.lightingOpen1 = a5[1]
          const a6 = resdata.lightingShut.split(',')
          this.temp.lightingShut = a6[0]
          this.temp.lightingShut1 = a6[1]
          const a7 = resdata.promptOpen.split(',')
          this.temp.promptOpen = a7[0]
          this.temp.promptOpen1 = a7[1]
          const a8 = resdata.promptShut.split(',')
          this.temp.promptShut = a8[0]
          this.temp.promptShut1 = a8[1]
          const a9 = resdata.hotOpen.split(',')
          this.temp.hotOpen = a9[0]
          this.temp.hotOpen1 = a9[1]
          const a10 = resdata.hotShut.split(',')
          this.temp.hotShut = a10[0]
          this.temp.hotShut1 = a10[1]
          this.listLoading = false
        })
      },
      save() {
        const temData = Object.assign({}, this.temp)
        this.list = temData
        this.list.screenOpen += ',' + this.list.screenOpen1
        this.list.screenShut += ',' + this.list.screenShut1
        this.list.lampOpen += ',' + this.list.lampOpen1
        this.list.lampShut += ',' + this.list.lampShut1
        this.list.lightingOpen += ',' + this.list.lightingOpen1
        this.list.lightingShut += ',' + this.list.lightingShut1
        this.list.promptOpen += ',' + this.list.promptOpen1
        this.list.promptShut += ',' + this.list.promptShut1
        this.list.hotOpen += ',' + this.list.hotOpen1
        this.list.hotShut += ',' + this.list.hotShut1
        sureEdit(this.list).then(response => {
          this.$notify({
            title: '成功',
            message: '提交修改成功',
            type: 'success'
          })
        })
      }
    }
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .filter-container{
    padding-bottom: 10px;
  }
  .table {
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
    border-radius: 0 !important;
    border: 1px solid #dddddd;
    min-height: 100%;
    padding-bottom: 0;
    font-family: 'Open Sans';
    font-size: 13px;
    color: #666;
    line-height: 1.5;
  }
  .table-striped > tbody > tr:nth-child(odd) {
    background-color: #f9f9f9;
  }
  .table > thead > tr > th, .table > tbody > tr > th, .table > tfoot > tr > th, .table > thead > tr > td, .table > tbody > tr > td, .table > tfoot > tr > td {
    padding: 8px;
    line-height: 1.42857143;
    vertical-align: top;
    border-top: 1px solid #dddddd;
  }
  .table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
    border-right: 1px solid #dddddd;
  }
  select {
    padding: 3px 4px;
    height: 32px;
    margin-top: 0;
    border-radius: 0;
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
    color: #858585;
    background-color: #ffffff;
    border: 1px solid #d5d5d5;
  }
  select option, select.form-control option {
    padding: 3px 4px 5px;
  }
  textarea, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"] {
    border-radius: 0 !important;
    color: #858585;
    background-color: #ffffff;
    border: 1px solid #d5d5d5;
    padding: 4px 4px 5px;
    font-size: 14px;
    font-family: inherit;
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
    -webkit-transition-duration: 0.1s;
    transition-duration: 0.1s;
  }
  .center, .align-center {
    text-align: center !important;
  }
</style>
